<?php

if (validation_errors()) :
?>
<div class='alert alert-block alert-error fade in'>
    <a class='close' data-dismiss='alert'>&times;</a>
    <h4 class='alert-heading'>
        <?php echo lang('post_errors_message'); ?>
    </h4>
    <?php echo validation_errors(); ?>
</div>
<?php
endif;

$id = isset($post->id) ? $post->id : '';

?>
<section class="content-header">
    <h1>
                修改文章
    </h1>
</section>
<section class="content">
<style type="text/css">
    .form-group-m-b{margin-bottom: 15px;}
    em{display: block;height: 15px;}
    .form1_col .col-xs-2{padding-right: 0;}
    .checkbox-1{margin-top:25px ;}
    .thumbnail-lp{width: 100%;border: 1px solid #DFDFDF; position: relative;}
    .thumbnail-lp img,.lp-pic img,.door_pic img{width: 100%;margin: 0 auto;}
    .lp-pic{width: 100%;border: 1px solid #DFDFDF;min-height: 250px;position: relative;}
    .lp-pic .form-control{width: 90%; margin: 10px auto;}
    .door_pic{width: 49%;border: 1px solid #DFDFDF; min-height: 200px;position: relative;}
    .lptype{display: none;}
    .addpicbg{cursor: pointer;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);-webkit-transform:  translate(-50%,-50%);}
    .pic_delete{position: absolute;right: 10px; top: 10px;display: none;}
    .pic_edit{position: absolute;right: 60px; top: 10px;display: none;}
    .text-danger:hover{color: #dd4b39;}
    .picbg-parent{position: relative;height: 200px;}
        .pic_parent{position: relative;}
</style>
<script>
        var  id_pc_arr = <?php echo $post->pic_array_pc;?>;
        var  id_mobile_arr = <?php echo $post->pic_array_mobile;?>;
</script>
  <div class="row">
    <!-- form start -->
<!--     <?php //echo form_open($this->uri->uri_string(), 'class="form-horizontal" onkeydown="if(event.keyCode==13){return false;}"'); ?> -->
    <div class="col-md-9">
            <div class="box-body" style="padding: 0;">
                <div class="clearfix">
                    <input id='title'  class="form-control" placeholder="在此输入标题" style="font-size: 18px;" value="<?php echo set_value('title', isset($post->title) ? $post->title : ''); ?>"  />
                    <input id='project'  class="form-control" placeholder="所属项目名称" style="font-size: 18px;margin-top: 15px;" value="<?php echo set_value('project_name', isset($post->project_name) ? $post->project_name : ''); ?>"  />
                    <input type="hidden" id="new_id" value="<?php echo $post->id; ?>">
                    <input id='building_code'  class="form-control" placeholder="项目编码" style="font-size: 18px;margin-top: 15px;" value="<?php echo set_value('building_code', isset($post->building_code) ? $post->building_code : ''); ?>"  />
                    <input type="hidden" id="new_id" value="<?php echo $post->id; ?>">
                  
                    <div class="col-lg-12 editor_hide" <?php if($post->campaign_mode == 1) {echo "style='display: block;'";}else{echo "style='display: none;'";} ?>  >
                            <textarea id="editor1" name="editor1" class="editor1" style="padding: 0;"><?php echo $post->content;?></textarea>
                    </div>
                </div>
            </div>
            <em></em>
             <!--特色图片beg-->
            <div class="box box-danger feature_pic" <?php if($post->campaign_mode == 2) {echo "style='display: block;'";}else{echo "style='display: none;'";} ?>>
                <div class="box-header with-border">
                  <h3 class="box-title">特色图片</h3>
                  <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                    <i class="fa fa-minus"></i>
                  </button>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                              <div class="clearfix">
                                  <div class="pull-left door_pic text-center" id="container_info_pc">
                                    <?php
                                        if ($post->pc_imgs) :
                                        foreach ($post->pc_imgs as $key=>$value) :
                                    ?> 

                                          <div class="pic_parent " id="parent_<?php echo $value->id;?>" >
                                                <img src="<?php echo $value->absolute_pic;?>" width="100">
                                                <button class="btn btn-default btn-sm pic_edit" id="edit_<?php echo $value->id;?>">修改</button>
                                                <button class="btn btn-default btn-sm pic_delete">删除</button>
                                                <input type="hidden" name="pc_url[]" value="<?php echo $value->url;?>" style="display:none;" />
                                          </div>
                                    <?php
                                        endforeach;
                                        endif; 
                                    ?> 
                                          <div class="picbg-parent info_pc">
                                            <div class="addpicbg" id="pc_info_pickfiles">
                                                               <span class="fa fa-file-image-o" style="font-size: 40px;color: #a94442;"></span><br /><br />
                                                               <span class="text-danger">添加特色照片（Large）</span>
                                                         </div>
                                          </div>
                                  </div>
                                  <div class="pull-right door_pic text-center" id="container_info_mobile">
                                    <?php
                                        if ($post->mobile_imgs) :
                                        foreach ($post->mobile_imgs as $key=>$value) :
                                    ?>
                                          <div class="pic_parent " id="parent_<?php echo $value->id;?>">
                                                <img src="<?php echo $value->absolute_pic;?>" width="100">
                                                <button class="btn btn-default btn-sm pic_edit" id="edit_<?php echo $value->id;?>">修改</button>
                                                <button class="btn btn-default btn-sm pic_delete">删除</button>
                                                <input type="hidden" name="mobile_url[]" value="<?php echo $value->url;?>" style="display:none;" />
                                          </div>
                                   <?php
                                        endforeach;
                                        endif; 
                                    ?>      
                                    <div class="picbg-parent info_mobile" >
                                      <div class="addpicbg" id="mobile_info_pickfiles">
                                          <span class="fa fa-file-image-o" style="font-size: 40px;color: #a94442;"></span><br /><br />
                                          <span class="text-danger">添加特色照片（Small）</span>
                                      </div>
                                    </div>  
                                  </div>
                              </div>
                </div>
                  <!-- /.box-body -->
              </div>
              <!--特色图片end-->

               <!--链接beg-->
            <div class="box box-danger words_href" <?php if($post->campaign_mode == 3) {echo "style='display: block;'";}else{echo "style='display: none;'";}  ?>>
                <div class="box-header with-border">
                  <h3 class="box-title">链接</h3>
                  <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                    <i class="fa fa-minus"></i>
                  </button>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <input  class="form-control" placeholder="请输入链接" value="<?php echo $post->target_link;?>" />   
                </div>
                  <!-- /.box-body -->
              </div>
              <!--链接end-->

               <!--工具条beg-->
            <div class="box box-danger">
                <div class="box-header with-border">
                  <h3 class="box-title">工具条</h3>
                  <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                    <i class="fa fa-minus"></i>
                  </button>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <div class="clearfix">
                        <label class="checkbox-inline">
                          <input type="checkbox" id="show-phone"  class="minimal" value="1" <?php if($post->phone_switch == 1){ echo "checked";}?> > 显示电话
                        </label>
                        <label class="checkbox-inline">
                          <input type="checkbox" id="show-yuyue"  class="minimal" value="1" <?php if($post->yuyue_switch == 1){ echo "checked";}?> > 显示预约看房
                        </label>
                        <label class="checkbox-inline">
                          <input type="checkbox" id="show-hx" class="minimal" value="1" <?php if($post->hx_switch == 1){ echo "checked";}?> > 显示户型
                        </label>
                    </div>
                </div>
                  <!-- /.box-body -->
              </div>
              <!--工具条end-->
                 <div class="box box-danger">
                  <div class="box-header with-border">
                    <h3 class="box-title">分机号设置</h3>
                    <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                      <i class="fa fa-minus"></i>
                      </button>
                  </div>
                  <!-- /.box-header -->
                  <?php if(isset($ext_arrs) && !empty($ext_arrs)) : ?>
                  <?php foreach ($ext_arrs as $ext_arr) : ?>
                  <div class="box-body">
                      <div class="col-sm-2">
                          <select class="form-control select2" style="width: 100%;" name="plat[]">
                            <option value="1" <?php if(isset($ext_arr->platform) && 1==$ext_arr->platform): ?>selected<?php endif; ?>>PC端</option>
                            <option value="2" <?php if(isset($ext_arr->platform) && 2==$ext_arr->platform): ?>selected<?php endif; ?>>手机端</option>
                          </select>
                        </div>
                      <div class="col-sm-4">
                          <select class="form-control select2" style="width: 100%;" name="channel_id[]">
                            <?php foreach ($channels as $channel) : ?>
                            <option value="<?php echo $channel->id; ?>" <?php if(isset($ext_arr->channel_id) && $channel->id==$ext_arr->channel_id): ?>selected<?php endif; ?> ><?php echo $channel->name; ?></option>
                            <?php endforeach; ?>
                          </select>
                      </div>
                      <div class="col-sm-4" style="padding-right: 0px;">
                          <input type='text' name="number[]" maxlength='25' class="form-control" value="<?php echo set_value('number', isset($ext_arr->number) ? $ext_arr->number : ''); ?>" placeholder="分机号/400号码" style="font-size: 18px;margin-top: 3px;" />
                      </div>
                      <?php if(end($ext_arrs) == $ext_arr) :?><a style="margin-left:20px" href="javascript:;" class="add-channel">增加</a><?php endif;?>
                      <a style="margin-left:20px" href="javascript:;" class="del-channel">删除</a>  
                </div>
                <?php endforeach; ?>
                <?php else:?>
                    <div class="box-body">
                      <div class="col-sm-2">
                          <select class="form-control select2" style="width: 100%;" name="plat[]">
                            <option value="1" <?php if(isset($ext_arr->platform) && 1==$ext_arr->platform): ?>selected<?php endif; ?>>PC端</option>
                            <option value="2" <?php if(isset($ext_arr->platform) && 2==$ext_arr->platform): ?>selected<?php endif; ?>>手机端</option>
                          </select>
                      </div>
                      <div class="col-sm-4">
                          <select class="form-control select2 tmp" style="width: 100%;" name="channel_id[]">
                            <?php foreach ($channels as $channel) : ?>
                            <option value="<?php echo $channel->id; ?>"><?php echo $channel->name; ?></option>
                            <?php endforeach; ?>
                          </select>
                      </div>
                      <div class="col-sm-4" style="padding-right: 0px;">
                          <input type='text' name="number[]" maxlength='25' class="form-control" value="<?php echo set_value('number', isset($phone->number) ? $phone->number : ''); ?>" placeholder="分机号/400号码" style="font-size: 18px;" />
                      </div>  
                      <a style="margin-left:20px" href="javascript:;" class="add-channel">增加</a>
                      <a style="margin-left:20px" href="javascript:;" class="del-channel">删除</a>
                  </div>
                <?php endif;?>
                  <!-- /.box-body -->
            </div>
        </div>

        <div class="col-md-3">
        <!--发布beg-->
        <div class="box box-danger">
            <div class="box-body form-horizontal">
                <div class="box-body">
                    <button type="2" action="1"   id="sub" name='save' class="col-xs-6 btn btn-danger btn-lg">发布</button>
                    <button type="button" class="col-xs-4 btn btn-default btn-lg" style="margin-left: 10px;">预览</button>
                </div>
                <div class="box-body">状态：<span>已发布</span></div>
                <div class="clearfix">
                    <div class="col-xs-5">
                    <select class="form-control" id="status">
                        <option value="2" <?php if($post->status == 2){echo "selected";}?> >已发布</option>
                        <option value="4" <?php if($post->status == 4){echo "selected";}?> >等待复审</option>
                        <option value="1" <?php if($post->status == 1){echo "selected";}?> >草稿</option>
                    </select>
                </div>
                <div class="col-xs-7" style="margin-left: -20px;">
                    <button type="2" action="2" id="sub" class="col-xs-6 btn btn-danger">确定</button>
                    <button type="button" class="col-xs-5 btn btn-default pull-right">取消</button>
                </div>
                </div>
                <em></em>
                <em></em>
                <em></em>
                <div class="box-body">发布于：2016年3月2日 @ 15:12</div>
              </div>
              <!-- /.box-body -->
         </div>
        <!--发布end-->    
        <!--缩略图beg-->
        <div class="box box-danger">
            <div class="box-header with-border">
                <h3 class="box-title">缩略图</h3>
                <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                    <i class="fa fa-minus"></i>
                </button>
            </div>
            <div class="box-body" id="container">
                <div class="thumbnail-lp pic_parent campaign_pic">
                <?php if(isset($post->source_pic) && !empty($post->source_pic)) :?>
                              <img src="<?php echo $post->absolute_url_news; ?>" id="building_thumb_img" style="width: 100%; " />
                              <input type="hidden" name="url" id="url" value="<?php echo $post->source_pic; ?>" style="display:none;" />
                <?php endif;?>
                        </div>
                <em></em>
                <a href="#" id="source_pic">修改缩略图</a>
            </div>
        </div>
        <!--缩略图end-->
        <!--文章分类end-->    
        <div class="box box-danger">
            <div class="box-header with-border">
              <h3 class="box-title">新闻分类</h3>
                <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                    <i class="fa fa-minus"></i>
              </button>
            </div>
            <!-- /.box-header -->
              <div class="box-body form-horizontal">
              <?php if(isset($categories) && !empty($categories)) : ?>
              <?php foreach ($categories as $category) : ?>
                <div class="form-group">
                    <div class="col-sm-12">
                        <input type="checkbox" class="minimal" name="category[]" value="<?php echo $category->tag_id; ?>" id="category_<?php echo $category->tag_id; ?>" <?php echo isset($category->selected) ? 'checked' : ''; ?> />
                        <?php echo form_label($category->tag_name, 'category_'.$category->tag_id, array()); ?>
                    </div>
                </div>
              <?php endforeach; ?>
              <?php endif; ?>
                 <a href="javascript:;" class="add-lptype">+ 添加新闻类型</a>
                <div class="lptype">
                    <em></em>
                    <div class="form-group col-sm-12">
                        <input id='add_news_type' type='text' name='add_news_type' maxlength='100' class="form-control" value=""  />
                    </div>
                    <button action="1" class="add_new_cate" class="btn btn-danger">添加新闻类型</button>
                </div>
              </div>
              <!-- /.box-body -->
          </div>    
         <!--文章分类end-->   
        <!--类型beg-->    
        <div class="box box-danger">
            <div class="box-header with-border">
              <h3 class="box-title">类型</h3>
              <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                    <i class="fa fa-minus"></i>
              </button>
            </div>
            <!-- /.box-header -->
              <div class="box-body form-horizontal">
                <div class="form-group">
                    <div class="col-sm-12">
                        <div class="radio">
                            <label>
                                <input type="radio" name="optionsRadios" class="radioItem"  value="1" <?php if($post->campaign_mode == 1){ echo "checked";}?> />普通
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="optionsRadios" class="radioItem" value="2" <?php if($post->campaign_mode == 2){ echo "checked";}?> />图片
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="optionsRadios" class="radioItem" value="3" <?php if($post->campaign_mode == 3){ echo "checked";}?> />链接
                            </label>
                        </div>
                    </div>
                </div>
              </div>
              <!-- /.box-body -->
          </div>    
         <!--类型end-->   
                 <!--渠道开始-->    
        <div class="box box-danger">
            <div class="box-header with-border">
              <h3 class="box-title">选择渠道</h3>
              <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                  <i class="fa fa-minus"></i>
              </button>
            </div>
            <!-- /.box-header -->
              <div class="box-body form-horizontal">

                              <select class="form-control select2" id="channel">
                                          <?php if(isset($channels) && !empty($channels)) : ?>
                                          <?php foreach ($channels as $channels) : ?>
                                              <option value="<?php echo $channels->id;?>" <?php if($channels->id == $post->channel){echo "selected";} ?> ><?php echo $channels->name;?></option>
                                          <?php endforeach; ?>
                                          <?php endif;?>
                              </select>

                 <a href="javascript:;" class="add-lptype">+ 添加新闻类型</a>

              </div>
              <!-- /.box-body -->
          </div>    
         <!--渠道end-->   
        <!--标签beg-->
           <div class="box box-danger">
            <div class="box-header with-border">
              <h3 class="box-title">标签</h3>
              <button type="button" class="btn btn-box-tool pull-right" data-widget="collapse">
                    <i class="fa fa-minus"></i>
              </button>
            </div>

              <div class="box-body form-horizontal add-post-tag">
                <div class="form-group">
                    <div class="col-sm-10">
                                      <select class="form-control select2" style="width: 100%;" name="tags[]" id="add_tag_name" multiple="multiple">
                                            <?php foreach ($normal_tags as $key=>$value) : ?>
                                                <option value="<?php echo $value['tag_id']; ?>" selected><?php echo $value['tag_name']; ?></option>
                                           <?php endforeach; ?>
                                  </select>
                    </div>
                    <button action="2" id="add_tag" class="btn btn-danger add_new_cate">添加</button>
                </div>
                <a href="javascript:;">从常用标签中选择</a>
                </div>
                
              </div>
              <!-- /.box-body -->
          </div>
          <!--标签end-->
            <!-- /.box-header -->
              <div class="box-body form-horizontal">
                <div class="form-group">
                    
                    <div class="col-sm-12">
                        <img src="<?php echo Template::theme_url('images/avatar5.png'); ?>" id="building_thumb_img" style="width: 100%; display: none;" />
                        <input type="hidden" name="building_thumb_url" id="building_thumb_url" value="" style="display:none;" />
                    </div>
                </div>
                
              </div>
              <!-- /.box-body -->
          </div>

</section>